package doyyin;

import lombok.Data;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.Serializable;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Map;

@Data
public class test implements Serializable {
    static String followingUrl="https://www-hj.douyin.com/aweme/v1/web/user/following/list/?device_platform=webapp&aid=6383&channel=channel_pc_web&user_id=101698474497&sec_user_id=MS4wLjABAAAAVpIeSY_InKKDik9DB4op5Ttj5UEK46lWlna5VoE4gS8&offset=20&min_time=0&max_time=0&count=10&source_type=4&gps_access=0&address_book_access=0&is_top=1&update_version_code=170400&pc_client_type=1&pc_libra_divert=Windows&support_h265=1&support_dash=1&cpu_core_num=8&version_code=170400&version_name=17.4.0&cookie_enabled=true&screen_width=1536&screen_height=864&browser_language=zh-CN&browser_platform=Win32&browser_name=Chrome&browser_version=136.0.0.0&browser_online=true&engine_name=Blink&engine_version=136.0.0.0&os_name=Windows&os_version=10&device_memory=8&platform=PC&downlink=10&effective_type=4g&round_trip_time=100&webid=7494581555790186025&uifid=4be83ecefa579a300714166db9e569bafd8689fc248d1e190e384db8df203b81a32c9a0b72bebfad256c647900b4ef78e5aafc0fcf86d3a7e9d0256a7a9819b4e300b0bffd544added228ac07a31f37c4da215b614a5b51aba9f2349ee4c765982fe994039f84d60c0a4829e49be406d8bf228c2e14233b531e3f6e739146bce450c8335590b6bae8ca8e9fe1eea37db065265be1e86322d5b449556d94113a7&verifyFp=verify_m9ml1uqd_Z8cjHptX_wUEn_4FCk_90v5_HnQnjVqrfJNd&fp=verify_m9ml1uqd_Z8cjHptX_wUEn_4FCk_90v5_HnQnjVqrfJNd&msToken=jznGzPo-n8WVtpGpLCycaeDWQHEDoElJ1TqBN1hAWRDd6TUKltbLqi3omiLUEluBhd4C3GFZ1Hql4EL3tTHx1RFnXC6jthSf-XrqURd_XCk8pAwhnLwIJwxZ6SOu2wP2x3QWcfg_nbcXLefEcWmm9UOlkiYej9CLSnVEgSSSrEGs&a_bogus=d64fDwtLQ2AncdKtYOPCyUcl7KEMNTWyfZiOWLZT7PYaGqtc5uP4dabobxqhJIrauSMkk13H-J4lunxc%2FTUwZe9kKmpvu2syQz5VngfL21N6Y0JQLqgkez4zoXMK8YGza%2FV9i1JIhUGw1jd-iqdE%2FBVSeKOK5Y8h%2F3ORk2TSx9ah1z6AgZnaPQSdThGqYD%3D%3D"
            ;
    static String cookie =
            "ttwid=1%7CocftL6xCqrSxZ3jVcfpxPb0L4UEcUV1SvCNxtpt3hb0%7C1744968265%7C0aaf9c48f6eb9c0ee744f61e2aa0a513a4d8ece62eeb19996a2108f67d6965eb; UIFID_TEMP=4be83ecefa579a300714166db9e569bafd8689fc248d1e190e384db8df203b81602d4f0fea0b25756a6238e6d701adbf7d531ebafcb048094b90681740d351cea1bea466fe8b5b87c8b0e386e34eee7c; hevc_supported=true; passport_csrf_token=adb0fed9d98e0e4a2ca7375dbc8bc50a; passport_csrf_token_default=adb0fed9d98e0e4a2ca7375dbc8bc50a; __security_mc_1_s_sdk_crypt_sdk=7bd2078d-47b3-aa54; bd_ticket_guard_client_web_domain=2; UIFID=4be83ecefa579a300714166db9e569bafd8689fc248d1e190e384db8df203b81a32c9a0b72bebfad256c647900b4ef78e5aafc0fcf86d3a7e9d0256a7a9819b4e300b0bffd544added228ac07a31f37c4da215b614a5b51aba9f2349ee4c765982fe994039f84d60c0a4829e49be406d8bf228c2e14233b531e3f6e739146bce450c8335590b6bae8ca8e9fe1eea37db065265be1e86322d5b449556d94113a7; is_dash_user=1; volume_info=%7B%22isUserMute%22%3Afalse%2C%22isMute%22%3Afalse%2C%22volume%22%3A0.5%7D; FORCE_LOGIN=%7B%22videoConsumedRemainSeconds%22%3A180%2C%22isForcePopClose%22%3A1%7D; download_guide=%221%2F20250516%2F0%22; passport_assist_user=Cj0yCu8d5Ev50SeZ-2D7W7CX8Lq695WwpM07iOplsANOagMzUTCN2J2g3JW01KyI8cz0IHJE3ai7b4cSXDqwGkoKPAAAAAAAAAAAAABPAA5BJIvIyr25vdhKTpC18onbwNNhcOdrfUt2v0QKWX-cN2kCzgomk1Vr8_kbU1ulERCUwfENGImv1lQgASIBAyGJW78%3D; n_mh=WJJizOI1AeKSbz11BaKvElmRAa_ryfixssm0oqRsx1w; sid_guard=c12a19e44d69510e97e082dc69da5847%7C1747382385%7C5184000%7CTue%2C+15-Jul-2025+07%3A59%3A45+GMT; uid_tt=9da94aec6aaacf8ced046e1a81bcf2c9; uid_tt_ss=9da94aec6aaacf8ced046e1a81bcf2c9; sid_tt=c12a19e44d69510e97e082dc69da5847; sessionid=c12a19e44d69510e97e082dc69da5847; sessionid_ss=c12a19e44d69510e97e082dc69da5847; is_staff_user=false; sid_ucp_v1=1.0.0-KDVjODRlYzkzMDMyNjRjMmJlYTQ4ODEyMGE3NGZmZGVhYzAyZTljNTYKHwiBpM7t-gIQ8eCbwQYY7zEgDDDZgrDaBTgHQPQHSAQaAmxxIiBjMTJhMTllNDRkNjk1MTBlOTdlMDgyZGM2OWRhNTg0Nw; ssid_ucp_v1=1.0.0-KDVjODRlYzkzMDMyNjRjMmJlYTQ4ODEyMGE3NGZmZGVhYzAyZTljNTYKHwiBpM7t-gIQ8eCbwQYY7zEgDDDZgrDaBTgHQPQHSAQaAmxxIiBjMTJhMTllNDRkNjk1MTBlOTdlMDgyZGM2OWRhNTg0Nw; login_time=1747382385415; stream_player_status_params=%22%7B%5C%22is_auto_play%5C%22%3A0%2C%5C%22is_full_screen%5C%22%3A0%2C%5C%22is_full_webscreen%5C%22%3A0%2C%5C%22is_mute%5C%22%3A0%2C%5C%22is_speed%5C%22%3A1%2C%5C%22is_visible%5C%22%3A0%7D%22; strategyABtestKey=%221747382388.434%22; SelfTabRedDotControl=%5B%5D; biz_trace_id=202e039a; _bd_ticket_crypt_cookie=837fb76f3a1497a2f7943983dd547bb4; __security_mc_1_s_sdk_sign_data_key_web_protect=fde5f81c-486d-892a; __security_mc_1_s_sdk_cert_key=c66b80b4-40de-bc5c; __security_server_data_status=1; publish_badge_show_info=%220%2C0%2C0%2C1747382389895%22; FRIEND_NUMBER_RED_POINT_INFO=%22MS4wLjABAAAAVpIeSY_InKKDik9DB4op5Ttj5UEK46lWlna5VoE4gS8%2F1747411200000%2F1747382394460%2F0%2F0%22; live_use_vvc=%22false%22; h265ErrorNum=-1; stream_recommend_feed_params=%22%7B%5C%22cookie_enabled%5C%22%3Atrue%2C%5C%22screen_width%5C%22%3A1536%2C%5C%22screen_height%5C%22%3A864%2C%5C%22browser_online%5C%22%3Atrue%2C%5C%22cpu_core_num%5C%22%3A8%2C%5C%22device_memory%5C%22%3A8%2C%5C%22downlink%5C%22%3A10%2C%5C%22effective_type%5C%22%3A%5C%224g%5C%22%2C%5C%22round_trip_time%5C%22%3A50%7D%22; my_rd=2; bd_ticket_guard_client_data=eyJiZC10aWNrZXQtZ3VhcmQtdmVyc2lvbiI6MiwiYmQtdGlja2V0LWd1YXJkLWl0ZXJhdGlvbi12ZXJzaW9uIjoxLCJiZC10aWNrZXQtZ3VhcmQtcmVlLXB1YmxpYy1rZXkiOiJCQUZVZWdyMDEyQmxMZGs1NTZMTkw2cFpUS2ZWaUhOamR0MXFncTJjdzVRVTJDOC9hcGlWRC92N2hvVUMyNEV3NGlibFBZU3p2aEJGYVZTcDFrTzRuRnc9IiwiYmQtdGlja2V0LWd1YXJkLXdlYi12ZXJzaW9uIjoyfQ%3D%3D; FOLLOW_LIVE_POINT_INFO=%22MS4wLjABAAAAVpIeSY_InKKDik9DB4op5Ttj5UEK46lWlna5VoE4gS8%2F1747411200000%2F1747382395102%2F0%2F1747383261425%22; home_can_add_dy_2_desktop=%221%22; odin_tt=b7ffcdad188b5be9e6e2c93c0c90423289675ac4ac82870f6e753881033432769fd4ff88f4ebc9e0eecfd18b41cbe20ad3aab989fe649acda5f150c697be30a8; IsDouyinActive=true"
            ;
    public static void main(String[] args) throws Exception {
        String urlStr = UrlUtils.getUrl(followingUrl);
        Map<String, String> queryParam = UrlUtils.getFirstQueryParams(followingUrl);

        URL url = new URL(UrlUtils.getUrlWithParams(urlStr, queryParam));
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();

        // 设置请求方法
        conn.setRequestMethod("GET");

        // 设置请求头（headers）
        conn.setRequestProperty("accept", "application/json, text/plain, */*");
        conn.setRequestProperty("accept-language", "zh-CN,zh;q=0.9");
        conn.setRequestProperty("bd-ticket-guard-iteration-version", "1");
        conn.setRequestProperty("bd-ticket-guard-version", "2");
        conn.setRequestProperty("bd-ticket-guard-web-sign-type", "1");
        conn.setRequestProperty("bd-ticket-guard-web-version", "2");
        conn.setRequestProperty("origin", "https://www.douyin.com");
        conn.setRequestProperty("priority", "u=1, i");
        conn.setRequestProperty("referer", "https://www.douyin.com/");
        conn.setRequestProperty("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36");
        // 设置 Cookie（注意字符串应简化或截断以提高可读性）
        conn.setRequestProperty("Cookie", cookie);
        // 连接
        conn.connect();
        // 读取响应
        int responseCode = conn.getResponseCode();
        System.out.println("HTTP Response Code: " + responseCode);

        BufferedReader reader = new BufferedReader(new InputStreamReader(responseCode == 200 ? conn.getInputStream() : conn.getErrorStream(), "UTF-8"));
        String line;
        StringBuilder response = new StringBuilder();
        while ((line = reader.readLine()) != null) {
            response.append(line).append("\n");
        }
        reader.close();

        System.out.println( response.toString());;
    }
}
